package com.atguigu.gmall.order.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author atguigu-mqx
 */
@Configuration
public class ThreadPoolConfig {

    //  定义一个线程池：
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        //  定义一个线程池： io : 密集型 2n cpu：密集型 n+1  n = 4
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                5,
                100,
                3,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(3)
        );
        return threadPoolExecutor;
    }
}
